package com.efounder.holder;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.efounder.activity.Order.OrderGoodAdapter;
import com.efounder.bean.GoodsBean;
import com.efounder.bean.OrderInfoBean;
import com.efounder.chat.utils.LXGlideImageLoader;
import com.efounder.mobilemall.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Marcello on 2018/9/17.
 */
public class OrderStoreInfoHolder extends BaseHolder<OrderInfoBean.DataBean.ShopsBean> {

    private  TextView tv_shipping_fee;
    private ImageView iv_warehouse;
    private RecyclerView order_rlv_goods;
    private  TextView tv_store_name;
    private List<GoodsBean> cartItems;
    private  OrderGoodAdapter adapter;

    public OrderStoreInfoHolder(ViewGroup parent, int id) {
        super(parent,id);
//        tv_shipping_fee = getView(R.id.tv_shipping_fee);
//        order_iv_select_express = getView(R.id.order_iv_select_express);
        order_rlv_goods = getView(R.id.order_rlv_goods);
        tv_store_name = getView(R.id.tv_store_name);
        iv_warehouse = getView(R.id.iv_warehouse);
        order_rlv_goods.setLayoutManager(new LinearLayoutManager(getContext()));
        cartItems= new ArrayList<>();
        adapter = new OrderGoodAdapter(cartItems);
        order_rlv_goods.setAdapter(adapter);
    }

    @Override
    public void setData( OrderInfoBean.DataBean.ShopsBean data) {
        cartItems.clear();
        cartItems.addAll(data.getGoods());
        adapter.notifyDataSetChanged(cartItems);
        OrderInfoBean.DataBean.ShopsBean.MallShopBean mallShop = data.getMallShop();
        if(mallShop!=null){
            tv_store_name.setText(mallShop.getShopName());
            LXGlideImageLoader.getInstance().displayRoundCornerImage(getContext(), iv_warehouse, mallShop.getShopBrandlog(),
                    R.drawable.shop, R.drawable.shop, 20);
        }



    }

    public TextView getTvShippingFee() {
        return tv_shipping_fee;
    }


    public OrderGoodAdapter getAdapter() {
        return adapter;
    }

    public RecyclerView getOrder_rlv_goods() {
        return order_rlv_goods;
    }
}
